package com.example.data.jpa.dao;

import com.example.data.jpa.entity.User;
import jakarta.persistence.EntityManager;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author fanhang
 */
public interface UserCriteriaOperation {
    /**
     * 第 3 种自定义
     */
    List<User> findCCriteriaImpl(int age, String remark);

    @Repository
    record UserCriteriaOperationImpl(EntityManager entityManager) implements UserCriteriaOperation {
        @Override
        public List<User> findCCriteriaImpl(int age, String remark) {
            CriteriaBuilder builder = entityManager.getCriteriaBuilder();
            CriteriaQuery<User> query = builder.createQuery(User.class);
//            query.where()
//            return jdbcTemplate.queryForList("select * from t_user where age = ? and remark = '?' ", User.class, age, remark);
            return null;
        }
    }
}
